<%--
  Created by IntelliJ IDEA.
  User: 吴慧跃
  Date: 2022/5/16
  Time: 10:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <title>echars报表</title>
    <link href="/static/css/bootstrap.css" rel="stylesheet">
    <script type="text/javascript" src="/static/js/jquery-3.2.1.js"></script>
    <script src="/static/js/echarts.js"></script>
</head>
<body>
<!-- 为 ECharts 准备一个定义了宽高的 DOM -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    var num=[];
    var names=[];
    // 指定图表的配置项和数据
    var option = {
        title: {
            text: '各项目场地数'
        },
        tooltip: {},
        legend: {
            data: ['数量']
        },
        xAxis: {
            data: names
        },
        yAxis: {},
        series: [
            {
                name: '数量',
                type: 'bar',
                data: num
            }
        ]
    };
    $.get("/manage/echars",function (list) {
        for (var i in list){
            num.push(list[i].num);
            names.push(list[i].tname);

        }
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    });


</script>
</body>
</html>
